<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

require_once '../config.php';
require_once 'Comment.php';

$m = new Lib\Comment( $db, 'bbq_comment' );

$nick = htmlspecialchars($_POST['nick']);
$commentId = htmlspecialchars($_POST['comment_id']);
$parentId = htmlspecialchars($_POST['parent_id']);
$comment = htmlspecialchars($_POST['comment']);

$time = time();

$res = $m->AddComment($parentId, $commentId, $time, $nick, $comment);

if ( $res ) {
    $r['err'] = 0;
    echo json_encode($r);
}else {
    $r['err'] = 1;
    echo json_encode($r);
}